{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">
                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="province" lay-search="" id="province"  lay-filter="province">
                                <option value="">---- 请选择出发省 ----</option>
                                {foreach name="province" item="vo"}
                                <option value="{$vo.district_id}" >{$vo.district}</option>
                                {/foreach}
                            </select>
                        </div>

                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="city" lay-search=""  id="city"  lay-filter="city">
                                <option value="">---- 请选择出发市 ----</option>
                            </select>
                        </div>

                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="district" lay-search=""  id="district"  lay-filter="district">
                                <option value="">---- 请选择出发区 ----</option>
                            </select>
                        </div>


                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="order_to_sheng" lay-search="" id="provinceB"  lay-filter="provinceB">
                                <option value="">---- 请选择目的地省 ----</option>
                                {foreach name="province" item="voo"}
                                <option value="{$voo.district_id}" >{$voo.district}</option>
                                {/foreach}
                            </select>
                        </div>

                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="order_to_shi" lay-search=""  id="cityB"  lay-filter="cityB">
                                <option value="">---- 请选择目的地市 ----</option>
                                <option value=""></option>
                            </select>
                        </div>

                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="order_to_qu" lay-search=""  id="districtB"  lay-filter="districtB">
                                <option value="">---- 请选择目的地区 ----</option>
                                <option value="" ></option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="status" lay-search="" class="layui-input">
                                <option  value="">不限</option>
                                <option  value="1">月结</option>
                                <option  value="2">次月结</option>
                                <option  value="3">次次月结</option>
                            </select>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="keyword" class="layui-input search" name="keyword" value="" placeholder="司机姓名|货主姓名"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="keyword1" class="layui-input search" name="keyword1" value="" placeholder="司机手机号码|货主手机号码"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="keyword2" class="layui-input search" name="keyword2" value="" placeholder="订单号"/>
                        </div>
                        <!--<div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">-->
                        <!--<select name="province" lay-search="" id="province"  lay-filter="province">-->
                        <!--<option value="">全部</option>-->
                        <!--<option value="1" >上架中</option>-->
                        <!--<option value="2" >已下架</option>-->
                        <!--</select>-->
                        <!--</div>-->
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="input-group" >
                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-external-link"></i> 批量导出</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelect"><i class="fa fa-external-link"></i> 全部导出</a></li>
                        </ul>
                    </div>
                </div>

            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('详情','{:url('detail')}?order_id={{d.order_id}}')" class="btn btn-warning btn-xs m-r-xs" title="详情">详情</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<textarea id="allidsForOut" class="hidden"></textarea>

{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("record/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: 100
//            ,toolbar: '#toolbarDemo'
//            ,defaultToolbar: ['filter', 'exports']
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type:'numbers', width: 80, title: '序号'}
//                , {field: 'banner_id', width: 80, title: 'ID', align: 'center'}
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'order_id', width: 50, title: 'ID', align: 'center'}
                , {field: 'order_num', width: 150, title: '运单单号', align: 'center'}
                , {field: 'user_gongsi', width: 150, title: '企业名称', align: 'center'}
                , {field: 'price', width: 170, title: '加盟商本单获得金额', align: 'center'}
                , {field: 'user_username', width: 120, title: '司机昵称', align: 'center'}
                , {field: 'user_phone', width: 120, title: '司机手机号码', align: 'center'}
                , {field: 'qy_username', width: 120, title: '发布人姓名', align: 'center'}
                , {field: 'qy_phone', width: 130, title: '发布人手机号码', align: 'center'}
                , {field: 'jiesuan_name', width: 100, title: '计算状态', align: 'center'}
                , {field: 'go_address', width: 150, title: '出发地', align: 'center'}
                , {field: 'to_address', width: 150, title: '目的地', align: 'center'}
                , {field: 'order_zc_time', width: 150, title: '装车时间', align: 'center'}
                , {field: 'order_dzxy_yf', width: 100, title: '定金金额', align: 'center'}
                , {field: 'order_freight', width: 100, title: '整单金额', align: 'center'}
                , {fixed: 'right', width:300, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('#allidsForOut').val(res.count2);
                $('.layui-cricle').viewer();//图片查看器
            }
        });
        //监听单元格编辑
        table.on('edit(testReload)', function(obj){
            var value = obj.value //得到修改后的值
                    ,data = obj.data //得到所在行所有键值
                    ,field = obj.field; //得到字段
            // layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
            var patrn = /^[0-9]*$/;
            if(!patrn.test(value)){
                layer.msg('排序值只能为数字',{icon:2,time:1500,shade: 0.1},function(){
                    //重载当前页表格
                    $(".layui-laypage-btn").click();
                });
                return false;
            }
            wk.changeSort(data.banner_id,"{:url('sort')}",field,value);
        });
        //监听状态开关操作
        form.on('switch(OnOff)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 1: num = 2;
            //用户状态
            wk.status(this.value,num, '{:url("isDown")}',obj);
        });

        //批量操作
        var $ = layui.$, active = {
            //批量导出订单
            excelAll:function () {
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('outExcel')}");
            },
            //全部导出
            excelAllNoSelect:function () {
                wk.excelAll($('#allidsForOut').val(),$('.layui-input').serialize(),"{:url('outExcel')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['order_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>